<template>
  <!-- 检查记录 -->
  <view class="goover">
    <u-tabs :list="list" lineColor="#2488F5" lineWidth="40" :current="activeIndex" :inactiveStyle="inactiveStyle"
      :activeStyle="{ color: '#2488F5' }" @click="tabsClick"></u-tabs>
    <view class="split-bar"></view>

    <view v-if="activeIndex == 0">
      <go-over-bag ref="goOverBag" :gooverCompanyId="options.companyId"></go-over-bag>
    </view>

    <view v-if="activeIndex == 1">
      <review-bag ref="reviewBag" :gooverCompanyId="options.companyId"></review-bag>
    </view>

    <!-- <custom-tab-bar :tabBarIndex="tabBarIndex" ref="tabRef" /> -->
  </view>
</template>

<script>
  import goOverBag from "./goOverBag.vue";
  import reviewBag from "./reviewBag.vue";
  import {
    whetherLogin
  } from "@/utils/util.js";

  export default {
    components: {
      goOverBag,
      reviewBag
    },
    data() {
      return {
        token: "",
        tabBarIndex: 1,
        activeIndex: 0,
        list: [{
            name: "检查记录",
            badge: {
              isDot: false,
            },
          },
          {
            name: "复查记录",
            badge: {
              isDot: false,
            },
          },
        ],
        options: {}
      };
    },
    onShow() {
      this.token = wx.getStorageSync("X-MINI-TOKEN");
      if (!this.token) {
        whetherLogin();
        return;
      }

      this.tabsClick({
        index: uni.getStorageSync("gooverIndex") || 0
      });
    },
    onLoad(options) {
      this.options = options
    },
    methods: {
      tabsClick(item) {
        if (!this.token) {
          whetherLogin();
          return;
        }

        this.activeIndex = item.index;
        uni.setStorageSync("gooverIndex", item.index); //记录检查记录模块当亲  大标题的index

        if (this.activeIndex == 0) {
          this.$nextTick(() => {
            this.$refs.goOverBag.init();
          });
        } else if (this.activeIndex == 1) {
          this.$nextTick(() => {
            uni.removeStorageSync("goOverBagIndex");
            this.$refs.reviewBag.init();
          });
        }
      },
    },
  };
</script>

<style lang="scss">
</style>